from django.db import models
import datetime


# Create your models here.
class Note(models.Model):
	title = models.CharField(maxlength=200)
	note = models.TextField()
	author = models.CharField(maxlength=100)
	created = models.DateTimeField(editable=False)
	modified = models.DateTimeField(editable=False)
	slug = models.SlugField(prepopulate_from=("title",))
	
	def save(self):
		if not self.id:
			self.created = datetime.date.today()
		self.modified = datetime.datetime.today()
		super(Note, self).save()
		
	def get_absolute_url(self):
		return "/%s/" % self.slug
	
	def __str__(self):
		return self.title
	
	class Admin:
		pass
		list_display = ('title', 'note', 'author', 'created', 'modified')
		search_fields = ['title', 'note', 'author', 'created', 'modified']
	